package cn.ustb.serviceImpl;

import cn.ustb.dao.CourseScheduleDao;
import cn.ustb.entity.CourseSchedule;
import cn.ustb.service.CourseScheduleService;
import cn.ustb.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @author yuyan
 */
public class CourseScheduleServiceImpl implements CourseScheduleService {
    @Override
    public List<CourseSchedule> getCourseSchedule(String studentId, String yearTerm, String week) {
        SqlSession sqlSession=null;
        try{
            sqlSession= MyBatisUtil.getInstance();
            CourseScheduleDao courseScheduleDao=sqlSession.getMapper(CourseScheduleDao.class);
            return courseScheduleDao.getAllWithYearTerm(studentId, yearTerm, week);
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            if (sqlSession!=null){
                sqlSession.close();
            }
        }
        return null;
    }

    @Override
    public List<CourseSchedule> getTeacherAllCourse(String teacher){
        SqlSession sqlSession=null;
        try{
            sqlSession= MyBatisUtil.getInstance();
            CourseScheduleDao courseScheduleDao=sqlSession.getMapper(CourseScheduleDao.class);
            return courseScheduleDao.getTeacherAllCourse(teacher);
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            if (sqlSession!=null){
                sqlSession.close();
            }
        }
        return null;
    }
}
